home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-119 < prev    next >
Text File  |  1995-12-31  |  56KB  |  1,503 lines

  1. C.S.M.P. Digest             Tue, 31 Oct 95       Volume 3 : Issue 119
  2.  
  3. Today's Topics:
  4.  
  5.         I've hit a brick wall!
  6.         Implementing Command-. and Escape for cancel in dialogue
  7.         PPC ProcPtr functions?
  8.         Perl for Mac?
  9.         Popup Menus in 9-pt geneva ?????
  10.         Q: using OSAExecute to singlestep AppleScript
  11.         Reading Notification Manager queue?
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  16. (pottier@clipper.ens.fr).
  17.  
  18. The digest is a collection of article threads from the internet newsgroups
  19. comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for
  20. people who read news semi-regularly and want an archive of the discussions.
  21. If you don't know what a newsgroup is, you probably don't have access to
  22. it. Ask your systems administrator(s) for details. If you don't have access
  23. to news, you may still be able to post messages to the group by using a
  24. mail server like anon.penet.fi (mail help@anon.penet.fi for more
  25. information).
  26.  
  27. Each issue of the digest contains one or more sets of articles (called
  28. threads), with each set corresponding to a 'discussion' of a particular
  29. subject.  The articles are not edited; all articles included in this digest
  30. are in their original posted form (as received by our news server at
  31. nef.ens.fr).  Article threads are not added to the digest until the last
  32. article added to the thread is at least two weeks old (this is to ensure that
  33. the thread is dead before adding it to the digest).  Article threads that
  34. consist of only one message are generally not included in the digest.
  35.  
  36. The digest is officially distributed by two means, by email and ftp.
  37.  
  38. If you want to receive the digest by mail, send email to listserv@ens.fr
  39. with no subject and one of the following commands as body:
  40.     help                                Sends you a summary of commands
  41.     subscribe csmp-digest Your Name     Adds you to the mailing list
  42.     signoff csmp-digest                 Removes you from the list
  43. Once you have subscribed, you will automatically receive each new
  44. issue as it is created.
  45.  
  46. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  47. Questions related to the ftp site should be directed to
  48. scott.silver@dartmouth.edu.
  49.  
  50. -------------------------------------------------------
  51.  
  52. >From Keith Wiley <keithw@wam.umd.edu>
  53. Subject: I've hit a brick wall!
  54. Date: Mon, 2 Oct 1995 23:01:19 -0400
  55. Organization: University of Maryland College Park
  56.  
  57. Ok, I can't continue until I learn how to segment my project because I've 
  58. hit the 32K limit.  I posted some questions earlier and got several 
  59. responses, thank you.  However, I still have some major problems.
  60.  
  61. Aside from making header files, (I gave up on that temporarily), I'm just 
  62. trying to put a full copy of all #define, #include, typedefs, and globals 
  63. at the top of each .c source file.  It seems to work except that I get 
  64. link errors complaining about multidefined global variables.  If I 
  65. eliminate the declarations from all but one file then I get undeclared 
  66. errors (of course).  I can't figure out how to get around this.  I'm 
  67. putting extern in all the declarations.  I've tried putting extern in all 
  68. files except the one with main().  I've tried everything.  What do I need 
  69. to do?
  70.  
  71. Also, what's up with making header files?
  72.  
  73. . . .. ... ..... ........ ............. .....................
  74. .. ... ..... ....... ........... ............. .................
  75. . .. .... ........ ................ ................................
  76. Keith Wiley, Electrogenetic Engineer             *
  77. University of Maryland at College Park            *   * *     *   *      *
  78. email:  keithw@wam.umd.edu                      ***    **   * *    **     *
  79. world wide web:  http://www.wam.umd.edu/~keithw        *     **   **    ***
  80.  
  81.  
  82. +++++++++++++++++++++++++++
  83.  
  84. >From albtrssp@crocker.com (Kevin Tieskoetter)
  85. Date: 3 Oct 1995 01:31:53 GMT
  86. Organization: Albatross Productions
  87.  
  88. In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>
  89. Keith Wiley <keithw@wam.umd.edu> writes:
  90.  
  91. > Aside from making header files, (I gave up on that temporarily), I'm just 
  92. > trying to put a full copy of all #define, #include, typedefs, and globals 
  93. > at the top of each .c source file.  It seems to work except that I get 
  94. > link errors complaining about multidefined global variables.  If I 
  95. > eliminate the declarations from all but one file then I get undeclared 
  96. > errors (of course).  I can't figure out how to get around this.  I'm 
  97. > putting extern in all the declarations.  I've tried putting extern in all 
  98. > files except the one with main().  I've tried everything.  What do I need 
  99. > to do?
  100.  
  101. You can't give up on making header files - they're unavoidable.
  102.  
  103. A header file's purpose is to contain:
  104.  
  105. a) a prototype of all of the functions in the .c file that you want
  106. other files to have access to
  107. b) any #defines, typedefs that are related to the .c file, but you want
  108. to have access to in any other files
  109. c) >>>extern<<< declarations for globals that are in the .c file that
  110. you want other files to have access to (I'll explain in a moment)
  111.  
  112. Notice that the common thread between the a, b, and c is that the
  113. header file is for things that you want other files to have access to.
  114. If you have a typedef structure in one .c file that you don't need to
  115. use in any other file, don't put it into the header file (well, you
  116. can, but it's good practice not to). Likewise, if you have a structure
  117. that you need to use in more than one .c file, put it in a header file,
  118. and include that header in each .c file that needs the structure.
  119.  
  120. If you're not familiar with prototypes, they are statements that tell
  121. the compiler how a particular function is called. If you open up any
  122. Macintosh header file (Dialogs.h for example), you'll find tons of
  123. prototypes. Protypes are simple. If your function looks like this:
  124.  
  125. short MyFunction(short myInput)
  126. {
  127.  ....code.....
  128.  return myShort;
  129. }
  130.  
  131. Your prototype would look like this:
  132.  
  133. short MyFunction(short myInput);
  134.  
  135.  
  136. Essentially, it's the declaration of the function, with a semicolon (;)
  137. after it. Prototypes are a wonderful thing - they allow the compiler to
  138. make sure you're calling your functions correctly and eliminate lots of
  139. errors later in the process. I recommend that you change your compiler
  140. settings to "Require Function Prototypes" and that you NEVER turn it
  141. off.
  142.  
  143. Now, globals. You ONLY want to define globals inside .c files. As you
  144. probably know, globals are defined like this:
  145.  
  146.  
  147. short  gMyGlobalVariable;
  148.  
  149. When the compiler encounters this, it says "Oh, I need to allocate
  150. space inside the code for this variable named "gMyGlobalVariable". If
  151. you were to put this global inside a .h file, you would be telling the
  152. compiler to allocate space for the variable every time it encountered
  153. the declaration. Since this is obviously an error, the compiler won't
  154. let you declare globals with the same name more than once (static
  155. globals are an exception, but you don't need to worry about those yet).
  156.  
  157. But your other files may also need access to the same global. The
  158. solution is to declare a sort of "prototype" for the global, which is
  159. called an "extern". It is done like this:
  160.  
  161. extern short gMyGlobalVariable;
  162.  
  163. When the compiler encounters an extern global, it just says to itself
  164. that "oh,  gMyGlobalVariable must be defined some other place; I'll let
  165. the code compiler, and I'll figure it out later".
  166.  
  167. When you declare a global that needs to be used in more than one file,
  168. you need to declare both the global itself (in the .c file) AND the
  169. "extern" global (in the corresponding .h file).
  170.  
  171.  
  172. Then, at the top of each of your .c files, figure out which of the .h
  173. files you need to include to get it to work correctly, and add those
  174. #include statements.
  175.  
  176.  
  177. You CANNOT get by in C without using .h files!
  178.  
  179.  
  180. Good luck!
  181.  
  182.  
  183. -kevin
  184.  
  185. //---------------------------------------------------------------------
  186.    Kevin Tieskoetter / Software Prestidigitator, Specular International
  187. //---------------------------------------------------------------------
  188.  
  189. +++++++++++++++++++++++++++
  190.  
  191. >From kenlong@netcom.com (Ken Long)
  192. Date: Tue, 3 Oct 1995 07:24:49 GMT
  193. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  194.  
  195. Keith Wiley (keithw@wam.umd.edu) wrote:
  196. : Ok, I can't continue until I learn how to segment my project because I've 
  197. : hit the 32K limit.  I posted some questions earlier and got several 
  198. : responses, thank you.  However, I still have some major problems.
  199.  
  200. In Think C 5, if you had a segment that was too big, it would just tell 
  201. you as a link error.  In Think C 7 it asks if you'd like your project 
  202. automatically segmented.
  203.  
  204. : Aside from making header files, (I gave up on that temporarily), I'm just 
  205. : trying to put a full copy of all #define, #include, typedefs, and globals 
  206. : at the top of each .c source file.  It seems to work except that I get 
  207. : link errors complaining about multidefined global variables.  
  208.  
  209. I try to simplify any projects I download, by putting all the source and 
  210. header data all in one file.  Strive for simplification anywhere possible.
  211. If a set of headers and source files merged end up being less than about 
  212. 90K it usually works fine.
  213.  
  214. All a header is, really, is a setup for that which is remaining.  Like a 
  215. newspaper headline is a header for the article.  The headboard of a bed 
  216. is nearest the head.  If you head your boat into the wind, the head (bow) 
  217. goes into the wind first.
  218.  
  219. Defines can go in one header file and be included by all files, as far as 
  220. I've seen, and give no errors.  Same with typedefs.  Global variables 
  221. MUST be delcared only once, in one file.  You do not need to "#include" 
  222. that file in any other file.  You merely make the declaration in the 
  223. other files that use the global variables *except* you put the keyword 
  224. "extern' infront of it.
  225.  
  226. Example:
  227.  
  228. In main.c, you say "short thisShort;" and, in events.c, *if* it uses that 
  229. variable, you say "extern short thisShort;" - it's that simple.
  230.  
  231. If you make a "MyProg.h" file and put "short thisShort;" in it and in both 
  232. main.c and event.c you say "#include "MyProg.h"" you will get a multiply 
  233. defined error on "thisShort"
  234.  
  235. : If I 
  236. : eliminate the declarations from all but one file then I get undeclared 
  237. : errors (of course).  I can't figure out how to get around this.  I'm 
  238. : putting extern in all the declarations.  I've tried putting extern in all 
  239. : files except the one with main().  I've tried everything.  What do I need 
  240. : to do?
  241.  
  242. If you put "extern" in front of *all* declarations, then it looks for the 
  243. declaration externally and doesn't find it because it's referred to an 
  244. external declaration every time.  
  245.  
  246. The rule of thumb is:  "Declare the global in the first file it's used 
  247. in, then declare it "extern" in any *subsequent* files it's used in."
  248.  
  249. Like this:
  250.  
  251. // FileOne.c
  252.  
  253. short thisIsADeclaration;
  254.  
  255. TheFunctionAtTheJunction ()
  256. {
  257.     thisIsADeclaration = 1;
  258.  
  259.     DoBackFlips (thisIsADeclaration);
  260. }
  261. // end of file.
  262.  
  263. //FileTwo.c
  264.  
  265. extern short thisIsADeclaration;
  266.  
  267. FunctionThatsMunchin ()
  268. {
  269.     thisIsADeclaration = 4;
  270.  
  271.     DanceTheBooGaLoo (thisIsADeclaration);
  272. }
  273. //end of file.
  274.  
  275. This stuff is in the manual.  RTFM!  This is not stuff than can be, or 
  276. needs to be "figured out."  It needs to be read and understood and SEEN.  
  277. Look at example source project.  SEE how they are.  Read up on the layout 
  278. and operation of the programming environment you are using and the C 
  279. programming language if need be.
  280.  
  281. If you don't have a manual, write to the publisher and see about getting 
  282. one. All header files do is define things that would normally be defined 
  283. IN the source file where what's defined is *used*.
  284.  
  285. If you open a source file which has headers included and select
  286. "Preprocess" from the appropriate menu, it will make a new file where all
  287. the definitions and source are contained within it.  No header files
  288. needed because everything that file uses is defined right in it. #defines
  289. are "eaten" and what was #defined before is replaced by what it was
  290. #defined as. In other words, the code is "washed" in preparation to
  291. compiling.  
  292.  
  293. Headers (predefinition/declaration before use) are needed, but header
  294. files are not needed.  They are ONLY for convenience of the programmer. 
  295. They save him typing, copying and pasting and make his source file nice
  296. and neat. 
  297.  
  298. Open a project where a .c file has a #include...  Now open that header 
  299. and select all and copy, then close it.  Now select the line in the 
  300. source that said "#include "ThatHeader.h" and paste.  The include line 
  301. will be replaced by that which was included.  It's included internally, 
  302. now.  That's the only difference.  You don't have to say to include it 
  303. because it's already included.
  304.  
  305. -Ken-
  306.  
  307. +++++++++++++++++++++++++++
  308.  
  309. >From carl.gustafson@ece.drexel.edu (Carl Gustafson)
  310. Date: 3 Oct 1995 11:57:59 GMT
  311. Organization: Imaging and Computer Vision Center, Drexel University
  312.  
  313. In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
  314. Keith Wiley <keithw@wam.umd.edu> wrote:
  315.  
  316. > Ok, I can't continue until I learn how to segment my project because I've 
  317. > hit the 32K limit.  I posted some questions earlier and got several 
  318. > responses, thank you.  However, I still have some major problems.
  319. > Aside from making header files, (I gave up on that temporarily), I'm just 
  320. > trying to put a full copy of all #define, #include, typedefs, and globals 
  321. > at the top of each .c source file.  It seems to work except that I get 
  322. > link errors complaining about multidefined global variables.  If I 
  323. > eliminate the declarations from all but one file then I get undeclared 
  324. > errors (of course).  I can't figure out how to get around this.  I'm 
  325. > putting extern in all the declarations.  I've tried putting extern in all 
  326. > files except the one with main().  I've tried everything.  What do I need 
  327. > to do?
  328. > Also, what's up with making header files?
  329.  
  330. What you need to do is face Cupertino, genuflect, and repeat three times:
  331. I'll try harder next time...
  332.  
  333. Actually, splitting your code into separate files to make separate
  334. segments is implementation dependent. (Think C and it's relatives) In
  335. other environments (MPW) you would use #pragma segment directives.
  336.  
  337. That said, you could also configure your compiler and linker to do a
  338. "model far" or "big link" build, where you have branch islands in the
  339. linked code, so that nothing is more than a 16-bit pc-relative jump away,
  340. allowing virtually unlimited code size. PPC-native apps don't use segments
  341. (or, as I say to my Intel-Inside buddies, segments are for worms.) Again,
  342. environment dependent.
  343.  
  344. Header files should contain declarations (definitions? I never keep the
  345. names straight) for only the externally visible entities in the associated
  346. source code file. If your source file refers to a name defined [<= there,
  347. that must be it!] in another source file, you #include the header file for
  348. that source file.
  349.  
  350. -- 
  351. Carl Gustafson
  352. Imaging and Computer Vision Center
  353. Drexel University, Philadelphia, Penna
  354. - ----------------------------------------------------------
  355. I don't speak for Drexel, and Drexel doesn't listen to me...
  356.  
  357. +++++++++++++++++++++++++++
  358.  
  359. >From sample@esltd.com (Don Sample)
  360. Date: Wed, 04 Oct 1995 15:53:31 -0400
  361. Organization: Enterprise Solutions Ltd
  362.  
  363. In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
  364. Keith Wiley <keithw@wam.umd.edu> wrote:
  365.  
  366. > Ok, I can't continue until I learn how to segment my project because I've 
  367. > hit the 32K limit.  I posted some questions earlier and got several 
  368. > responses, thank you.  However, I still have some major problems.
  369. > Aside from making header files, (I gave up on that temporarily), I'm just 
  370. > trying to put a full copy of all #define, #include, typedefs, and globals 
  371. > at the top of each .c source file.  It seems to work except that I get 
  372. > link errors complaining about multidefined global variables.  If I 
  373. > eliminate the declarations from all but one file then I get undeclared 
  374. > errors (of course).  I can't figure out how to get around this.  I'm 
  375. > putting extern in all the declarations.  I've tried putting extern in all 
  376. > files except the one with main().  I've tried everything.  What do I need 
  377. > to do?
  378. > Also, what's up with making header files?
  379. >  
  380. How you segment a program depends on what your development environment. 
  381. In MPW you use #pragma statements to tell the compiler/linker which
  382. segment to put functions into.  In the Symantec and Metrowerks IDEs you
  383. can move a file to a different segment by dragging it in the project
  384. window.  To create a new segment simply drag it down below the bottom
  385. 'totals' line in the project window.
  386.  
  387.  
  388. A header file is simply a text file.  You can put anything into it that
  389. you can put into a C source file.  By convention header file names have
  390. the sufix ".h" but they don't have to, you can use any valid file name. 
  391. Generally you put information into them which is shared between source
  392. files (#defines, typedefs, function prototypes, etc.)
  393.  
  394. To include a header file in your source you use the #include statement. 
  395. For example if you have created a header file named "MyHeader.h" you would
  396. include it using the statement:
  397.  
  398.     #include "MyHeader.h"
  399.  
  400. I suspect that you are trying to do something like "#include <MyHeader.h>"
  401. and the compiler is telling you that it can't find the file.  The angle
  402. brackets around a file name tell the compiler to look in a specific set of
  403. directories for the header file.  Generally you only use them when
  404. including files which came with the compiler.  For your own header files
  405. use the quotes, which will search the directories containing your source
  406. code for the header files.  (Exactly where the compiler looks for header
  407. files depends on your development environment, but a good general rule of
  408. thumb is that if you wrote the header file use "", and if it came with the
  409. compiler use <>.)
  410.  
  411. +++++++++++++++++++++++++++
  412.  
  413. >From urrostro@uxa.ecn.bgu.edu (Richard Rostrom)
  414. Date: 12 Oct 1995 04:05:46 GMT
  415. Organization: Educational Computing Network
  416.  
  417. Don Sample (sample@esltd.com) wrote:
  418. : In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
  419. : Keith Wiley <keithw@wam.umd.edu> wrote:
  420.  
  421. : > Aside from making header files, (I gave up on that temporarily), I'm just 
  422. : > trying to put a full copy of all #define, #include, typedefs, and globals 
  423. : > at the top of each .c source file.  It seems to work except that I get 
  424. : > link errors complaining about multidefined global variables.  If I 
  425. : > eliminate the declarations from all but one file then I get undeclared 
  426. : > errors (of course).  I can't figure out how to get around this. 
  427.  
  428. declare the global variables in one file. Put extern declarations of 
  429. those variables in each of your other files.
  430. To simplify your life, use an include file for the extern declarations, 
  431. so that all modules will use the same set of declarations.
  432.  
  433. This should be done for all typedefs and structs as well.
  434.  
  435. These should be two different files, BTW, as you don't want to include 
  436. the externs in the file where the globals are defined!
  437.  
  438. +++++++++++++++++++++++++++
  439.  
  440. >From skevill@tartarus.uwa.edu.au (Scott Kevill)
  441. Date: Sat, 14 Oct 1995 11:35:52 +0800
  442. Organization: The University of Western Australia
  443.  
  444. In article <45i46q$b0e@news.ecn.bgu.edu>, urrostro@uxa.ecn.bgu.edu
  445. (Richard Rostrom) wrote:
  446.  
  447. : Don Sample (sample@esltd.com) wrote:
  448. : : In article <Pine.ULT.3.91.951002225623.27668A-100000@rac5.wam.umd.edu>,
  449. : : Keith Wiley <keithw@wam.umd.edu> wrote:
  450. : : > Aside from making header files, (I gave up on that temporarily), I'm just 
  451. : : > trying to put a full copy of all #define, #include, typedefs, and globals 
  452. : : > at the top of each .c source file.  It seems to work except that I get 
  453. : : > link errors complaining about multidefined global variables.  If I 
  454. : : > eliminate the declarations from all but one file then I get undeclared 
  455. : : > errors (of course).  I can't figure out how to get around this. 
  456. : declare the global variables in one file. Put extern declarations of 
  457. : those variables in each of your other files.
  458. : To simplify your life, use an include file for the extern declarations, 
  459. : so that all modules will use the same set of declarations.
  460. : This should be done for all typedefs and structs as well.
  461. : These should be two different files, BTW, as you don't want to include 
  462. : the externs in the file where the globals are defined!
  463.  
  464. I don't know if it's good practice or not, but something I've done to make
  465. this easier goes like this:
  466.  
  467. //-----------------------------
  468. // Globals.h
  469. #ifdef __MAIN__
  470. #define extern
  471. #endif
  472.  
  473. extern int   a, b, c;
  474. extern char  d, e, f;
  475.  
  476. #undef extern
  477. //-----------------------------
  478. // Main.c
  479. #define __MAIN__
  480. #include "Globals.h"
  481. ....
  482. //-----------------------------
  483. // OtherFile.c
  484. #include "Globals.h"
  485. ....
  486.  
  487. It's a bit of a kludge I guess, but it means only one copy of the globals
  488. that I have to update each time. It could be bad that every file gets all
  489. the globals instead of just the ones it needs. 
  490.  
  491. Comments are welcome!
  492.  
  493. Scott Kevill.
  494. skevill@tartarus.uwa.edu.au
  495.  
  496. +++++++++++++++++++++++++++
  497.  
  498. >From sample@esltd.com (Don Sample)
  499. Date: Mon, 16 Oct 1995 13:52:21 -0400
  500. Organization: Enterprise Solutions Ltd
  501.  
  502. In article <skevill-1410951135520001@s187.dialup.uwa.edu.au>,
  503. skevill@tartarus.uwa.edu.au (Scott Kevill) wrote:
  504.  
  505. > I don't know if it's good practice or not, but something I've done to make
  506. > this easier goes like this:
  507. > //-----------------------------
  508. > // Globals.h
  509. > #ifdef __MAIN__
  510. > #define extern
  511. > #endif
  512. > extern int   a, b, c;
  513. > extern char  d, e, f;
  514. > #undef extern
  515. > //-----------------------------
  516. > // Main.c
  517. > #define __MAIN__
  518. > #include "Globals.h"
  519. > ....
  520. > //-----------------------------
  521. > // OtherFile.c
  522. > #include "Globals.h"
  523. > ....
  524. > It's a bit of a kludge I guess, but it means only one copy of the globals
  525. > that I have to update each time. It could be bad that every file gets all
  526. > the globals instead of just the ones it needs. 
  527. > Comments are welcome!
  528.  
  529. Except for 'extern' being a reserved word which I don't think many
  530. compilers will let you redefine, I've seen this general technique used by
  531. a lot of people, usually something like:
  532.  
  533. #ifndef __MAIN__
  534.   #define EXTERN extern
  535. #else
  536.   #define EXTERN
  537. #endif
  538.  
  539. EXTERN int a, b, c;
  540.  
  541. ---------------------------
  542.  
  543. >From cwatson@cam.org (Chris Watson)
  544. Subject: Implementing Command-. and Escape for cancel in dialogue
  545. Date: Tue, 03 Oct 1995 12:32:24 -0400
  546. Organization: Communications Accessibles Montreal, Quebec Canada
  547.  
  548. I have a movable modal dialogue and would like to implement the Command-.
  549. and escape keys to click the cancel button.  In modal dialogues, I use
  550. SetDialogCancelItem () but this does not seem to work in movable modal
  551. dialgues.
  552.  
  553. I know I have to check the keyDown event and all that, my question is
  554. whether to check the charcode or the keycode and how specifically to do
  555. that given a keyDown event.  I don't know what the values for the escape
  556. and '.' are either.
  557.  
  558. Thanks for any help!
  559.  
  560.  
  561. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  562.   H H      |                   |                                       |
  563.   | |      | Sean McBride      |                                       |
  564. H-C-C-O-H  | cwatson@cam.org   |   "Total destructive interference"    |
  565.   | |      | Montreal, Canada  |                                       |
  566.   H H      |                   |                                       |
  567. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  568.  
  569. +++++++++++++++++++++++++++
  570.  
  571. >From technic@seanet.com (Ronald N. Tjoelker)
  572. Date: Tue, 03 Oct 1995 15:07:41 -0700
  573. Organization: Seanet Online Services, Seattle WA
  574.  
  575. In article <cwatson-0310951232240001@cwatson.hip.cam.org>, cwatson@cam.org
  576. (Chris Watson) wrote:
  577.  
  578. > I have a movable modal dialogue and would like to implement the Command-.
  579. > and escape keys to click the cancel button.  In modal dialogues, I use
  580. > SetDialogCancelItem () but this does not seem to work in movable modal
  581. > dialgues.
  582. > I know I have to check the keyDown event and all that, my question is
  583. > whether to check the charcode or the keycode and how specifically to do
  584. > that given a keyDown event.  I don't know what the values for the escape
  585. > and '.' are either.
  586.  
  587.  
  588. if (event.what == keyDown)
  589. {
  590.      c = (event.message & charCodeMask);
  591.  
  592.      if (c == 13 || c == 3)                       /* return or enter */
  593.      {
  594.           done = true;
  595.      }
  596.      if ((c == '.' && event.modifiers & cmdKey) || c == 27) /* cmd . or esc */
  597.      {
  598.           done = true;
  599.      }
  600. }
  601.  
  602. +++++++++++++++++++++++++++
  603.  
  604. >From erichsen@pacificnet.net (Erichsen)
  605. Date: Tue, 03 Oct 1995 18:18:13 -0700
  606. Organization: Disorganized
  607.  
  608. In article <technic-0310951507410001@technic.seanet.com>,
  609. technic@seanet.com (Ronald N. Tjoelker) wrote:
  610.  
  611. > if ((c == '.' && event.modifiers & cmdKey) || c == 27) /* cmd . or esc */
  612.  
  613. When checking for a command-period, you should make sure it will also work
  614. on keyboards that require a cmd-shift to get to the period. There's a
  615. tech-note and some code that shows how to do it.
  616.  
  617. +++++++++++++++++++++++++++
  618.  
  619. >From cwatson@cam.org (Chris Watson)
  620. Date: Tue, 03 Oct 1995 22:07:20 -0400
  621. Organization: Communications Accessibles Montreal, Quebec Canada
  622.  
  623. In article <technic-0310951507410001@technic.seanet.com>,
  624. technic@seanet.com (Ronald N. Tjoelker) wrote:
  625.  
  626. >> I have a movable modal dialogue and would like to implement the Command-.
  627. >> and escape keys to click the cancel button.
  628. >> I know I have to check the keyDown event and all that, my question is
  629. >> whether to check the charcode or the keycode and how specifically to do
  630. >> that given a keyDown event.
  631. >
  632. >     c = (event.message & charCodeMask);
  633. >
  634. >     if (c == 13 || c == 3)    /* return or enter */
  635. >          done = true;
  636. >     if ((c == '.' && event.modifiers & cmdKey) || c == 27)
  637. >          done = true;
  638.  
  639. Perhaps my orignal post was not as clear as I had intended.  This isn't
  640. really a programming problem as much as a question of Mac human interface
  641. guidelines.
  642.  
  643. If I was to use the code you suggested a few issues are raised who's
  644. answers I'm not sure of.
  645.  
  646. First of all, does the state of the command key matter when testing the
  647. escape key?  Should Command-Escape also click cancel?
  648.  
  649. Next, if I use this code checking for a keypress with charCode == 27, then
  650. pressing the 'clear' key on the keypad will also click cancel, since
  651. escape and clear have the same char code.  Should I be checking the
  652. keyCode instead of the charCode?
  653.  
  654. Next, how about the period key?  Should the one on the keypad also be
  655. allowed?  If the user has set in the Numbers control panel that the
  656. decimal character be a ',' (comma) instead of a period should pressing the
  657. keypad 'period' also work?  Again, should I be checking for a keyCode or a
  658. charCode?
  659.  
  660. Lastly, if I do need to check the keyCode, how do I do this?  (this is a
  661. programming problem).  I know the charCode is event->message &
  662. charCodeMask, how do I extract the keyCode from the event?  event->message
  663. & keyCodeMask does not provide the correct value.
  664.  
  665. I hope this clears up what I mean... Thanks for any help!!
  666.  
  667. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  668.   H H      |                   |                                       |
  669.   | |      | Chris Watson      |                                       |
  670. H-C-C-O-H  | cwatson@cam.org   |   "Total destructive interference"    |
  671.   | |      | Montreal, Canada  |                                       |
  672.   H H      |                   |                                       |
  673. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  674.  
  675. +++++++++++++++++++++++++++
  676.  
  677. >From Francois-Regis.Degott@imag.fr (F. Degott)
  678. Date: 4 Oct 1995 13:46:49 GMT
  679. Organization: LMC-IMAG Grenoble France
  680.  
  681. In article <cwatson-0310952207200001@cwatson.hip.cam.org>, cwatson@cam.org
  682. (Chris Watson) wrote:
  683.  
  684. >[cut]
  685. >Lastly, if I do need to check the keyCode, how do I do this?  (this is a
  686. >programming problem).  I know the charCode is event->message &
  687. >charCodeMask, how do I extract the keyCode from the event?  event->message
  688. >& keyCodeMask does not provide the correct value.
  689. >
  690. >I hope this clears up what I mean... Thanks for any help!!
  691. >
  692.  
  693. Hi Chris,
  694.  
  695. to get the charCode and the keyCode of the event.message field:
  696.  
  697. Pascal:
  698. charCode:= char(BitAnd(event.message, charCodeMask));
  699. keyCode:= BitAnd(event.message, keyCodeMask) div 256;
  700.   
  701. C:
  702. charCode = (char)(event.message & charCodeMask);
  703. keyCode = (event.message & keyCodeMask) / 256; {or >>8}
  704.  
  705. keyCode for <escape key> = $35 (53 decimal)
  706. charCode for <escape key> = $1B (27 decimal)
  707.  
  708. HTH
  709. Fr
  710. ___________________________________________________________________________
  711. FR Degott (Francois-Regis.Degott@imag.fr)
  712. LogiMath, Lab. LMC-IMAG - Grenoble - France
  713.  
  714. +++++++++++++++++++++++++++
  715.  
  716. >From stk@berlin.snafu.de (Stefan Kurth)
  717. Date: Wed, 04 Oct 1995 18:11:56 +0100
  718. Organization: none
  719.  
  720. Chris Watson <cwatson@cam.org> wrote:
  721.  
  722. > I have a movable modal dialogue and would like to implement the Command-.
  723. > and escape keys to click the cancel button.  In modal dialogues, I use
  724. > SetDialogCancelItem () but this does not seem to work in movable modal
  725. > dialgues.
  726.  
  727. It does work in movable modal dialogs.  All you have to do is call the
  728. standard filter proc.  (GetStdFilterProc)
  729.  
  730.  
  731. -- 
  732. Stefan Kurth
  733. Berlin, Germany
  734.  
  735. +++++++++++++++++++++++++++
  736.  
  737. >From rdwells@mmm.com (Richard Wells)
  738. Date: 4 Oct 1995 23:14:00 GMT
  739. Organization: 3M Company
  740.  
  741. cwatson@cam.org (Chris Watson) wrote:
  742. >First of all, does the state of the command key matter when testing the
  743. >escape key?  Should Command-Escape also click cancel?
  744. >
  745. >Next, if I use this code checking for a keypress with charCode == 27, then
  746. >pressing the 'clear' key on the keypad will also click cancel, since
  747. >escape and clear have the same char code.  Should I be checking the
  748. >keyCode instead of the charCode?
  749. >
  750. >Next, how about the period key?  Should the one on the keypad also be
  751. >allowed?  If the user has set in the Numbers control panel that the
  752. >decimal character be a ',' (comma) instead of a period should pressing the
  753. >keypad 'period' also work?  Again, should I be checking for a keyCode or a
  754. >charCode?
  755. >
  756. >Lastly, if I do need to check the keyCode, how do I do this?  (this is a
  757. >programming problem).  I know the charCode is event->message &
  758. >charCodeMask, how do I extract the keyCode from the event?  event->message
  759. >& keyCodeMask does not provide the correct value.
  760.  
  761. One more example: try typing control-c when a dialog is displayed.  Most
  762. applications treat this the same as the enter key, and act as if the
  763. OK button was hit.  Of course, if your users are former DOS types, where
  764. control-c meant cancel, this is rather counter-intuitive.
  765.  
  766. BTW:  (event->message & keyCodeMask) >> 8 will give you the key code.
  767.  
  768.  
  769.  
  770. +++++++++++++++++++++++++++
  771.  
  772. >From cwatson@cam.org (Sean McBride)
  773. Date: Wed, 11 Oct 1995 19:40:19 -0400
  774. Organization: Communications Accessibles Montreal, Quebec Canada
  775.  
  776. In article <44v4fo$50g@dawn.mmm.com>, rdwells@mmm.com (Richard Wells) wrote:
  777.  
  778. >One more example: try typing control-c when a dialog is displayed.  Most
  779. >applications treat this the same as the enter key, and act as if the
  780. >OK button was hit.  Of course, if your users are former DOS types, where
  781. >control-c meant cancel, this is rather counter-intuitive.
  782.  
  783. That's an interesting point, but control-c produces the ascii character
  784. for the enter key (keypad) and I've found every other application allows
  785. this to me used.
  786.  
  787. Also, isn't it alt-c that cancels with dos, not control-c, since ascii is
  788. used with dos also?
  789.  
  790. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  791.   H H      |                   |                                       |
  792.   | |      | Sean McBride      |                                       |
  793. H-C-C-O-H  | cwatson@cam.org   |   "Total destructive interference"    |
  794.   | |      | Montreal, Canada  |   "For Unlawful Carnal Knowledge"     |
  795.   H H      |                   |                                       |
  796. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  797.  
  798. +++++++++++++++++++++++++++
  799.  
  800. >From rdwells@mmm.com (Richard Wells)
  801. Date: 12 Oct 1995 19:09:16 GMT
  802. Organization: 3M - St. Paul, MN  55144-1000 US
  803.  
  804. cwatson@cam.org (Sean McBride) wrote:
  805. >In article <44v4fo$50g@dawn.mmm.com>, rdwells@mmm.com (Richard Wells) wrote:
  806. >
  807. >>One more example: try typing control-c when a dialog is displayed.  Most
  808. >>applications treat this the same as the enter key, and act as if the
  809. >>OK button was hit.  Of course, if your users are former DOS types, where
  810. >>control-c meant cancel, this is rather counter-intuitive.
  811. >
  812. >That's an interesting point, but control-c produces the ascii character
  813. >for the enter key (keypad) and I've found every other application allows
  814. >this to me used.
  815. >
  816. >Also, isn't it alt-c that cancels with dos, not control-c, since ascii is
  817. >used with dos also?
  818.  
  819. No, its control-c, and therein lies the rub.  If a (reformed) DOS user
  820. tries to use control-c to cancel a Mac dialog (old habits do die hard),
  821. the program will almost always interpret that as a keypad enter, and act
  822. as if the OK button was hit.
  823.  
  824. To be honest, I've never actually seen a user get bit by this.  The way
  825. we found it was that we have some testing monkeys who, while hitting
  826. random keys in an effort to produce a Shakespeare sonnet, hit control-c
  827. while a dialog was displayed and were startled by the effect.
  828.  
  829. FWIW: control-c maps to ASCII 3, which is the ETX character.  I'm reasonably
  830. sure that ETX stands for "end transmission".  This (mostly reformed)
  831. programmer has to admit it makes more sense to interpret this as OK
  832. rather than cancel, especially since control-x is the ASCII CAN character,
  833. which I'm reasonably sure is short for "cancel".  But control-c had a
  834. long tradition of meaning "cancel" (or perhaps, more correctly, "stop") in
  835. old DEC systems (RSTS, VMS, and probably RT-11), and that is probably why
  836. it was adopted for MS-DOS.  (Also, CP/M may have used control-c for that
  837. purpose.  Its been awhile.  Have I given away my age yet?)
  838.  
  839.  
  840.  
  841. ---------------------------
  842.  
  843. >From quinlan@news.sfu.ca (Brian Quinlan)
  844. Subject: PPC ProcPtr functions?
  845. Date: 13 Oct 1995 20:52:36 GMT
  846. Organization: Simon Fraser University
  847.  
  848. In my program I use, like everyone else, a handler in my TrackControl
  849. call for my scrollbars. However, when I compile my program for PPC
  850. this produces a crash. That makes sense but how do I fix it?
  851.  
  852. --
  853.  
  854. Brian Quinlan
  855. quinlan@sfu.ca
  856.  
  857. +++++++++++++++++++++++++++
  858.  
  859. >From Darren Giles <mars@netcom.com>
  860. Date: Sun, 15 Oct 1995 19:40:00 GMT
  861. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  862.  
  863. In article <45mjik$crr@morgoth.sfu.ca> Brian Quinlan, quinlan@news.sfu.ca
  864. writes:
  865. >In my program I use, like everyone else, a handler in my TrackControl
  866. >call for my scrollbars. However, when I compile my program for PPC
  867. >this produces a crash. That makes sense but how do I fix it?
  868.  
  869.  
  870. The short answer: you need to create a Universal Procedure Pointer
  871. (UPP) for any callback routines.  This is quite simple:
  872.  
  873. In your globals:
  874.      ControlActionUPP     gMyTrackControlRoutineUPP;
  875.  
  876. In your initialization code:
  877.      gMyTrackControlRoutineUPP= NewControlActionProc
  878. (MyTrackControlRoutine)
  879.  
  880. When you call TrackControl:
  881.     result= TrackControl (theControl, &thePoint,
  882. gMyTrackControlRoutineUPP);
  883.  
  884.  
  885. - Darren
  886.  
  887. +++++++++++++++++++++++++++
  888.  
  889. >From rickc@i-link.net (Richard Cardona)
  890. Date: 15 Oct 1995 14:19:59 GMT
  891. Organization: TradeWave Corporation (formerly EINet)
  892.  
  893. In article <45mjik$crr@morgoth.sfu.ca>, quinlan@news.sfu.ca (Brian
  894. Quinlan) wrote:
  895.  
  896. > In my program I use, like everyone else, a handler in my TrackControl
  897. > call for my scrollbars. However, when I compile my program for PPC
  898. > this produces a crash. That makes sense but how do I fix it?
  899. > --
  900. > Brian Quinlan
  901. > quinlan@sfu.ca
  902.  
  903. Try reading Inside Macintosh : PowerPC System Software.  It will explain
  904. all about UniversalProcPtrs and how to fix your situation.  You could
  905. probably soak up what you need in 1 bookstore visit or go to Apple's Web
  906. site with Inside Mac online.
  907.  
  908. Rick
  909.  
  910. ---------------------------
  911.  
  912. >From adam@park78.demon.co.uk (Adam Lloyd)
  913. Subject: Perl for Mac?
  914. Date: Fri, 13 Oct 1995 18:32:00 +0100
  915. Organization: a sluggish molehill.
  916.  
  917. Are there any good implementations of Perl for the Mac, other than the Perl
  918. Tool for MPW? I'm thinking along the lines of something stand-alone...
  919.  
  920. Adam.
  921.  
  922.  
  923.  
  924. +++++++++++++++++++++++++++
  925.  
  926. >From neeri@iis.ee.ethz.ch (Matthias Neeracher)
  927. Date: 16 Oct 1995 16:41:52 GMT
  928. Organization: Integrated Systems Laboratory, ETH, Zurich
  929.  
  930. In article <ACA4612096681197B@park78.demon.co.uk>, adam@park78.demon.co.uk (Adam Lloyd) writes:
  931. > Are there any good implementations of Perl for the Mac, other than the Perl
  932. > Tool for MPW? I'm thinking along the lines of something stand-alone...
  933.  
  934. ftp://ftp.switch.ch/software/mac/perl/
  935. ftp://ftp.share.com/pub/macperl/
  936.  
  937. Matthias
  938.  
  939. - ---
  940. Matthias Neeracher <neeri@iis.ee.ethz.ch> http://err.ethz.ch/members/neeri.html
  941.    "One fine day in my odd past..." -- Pixies, _Planet of Sound_
  942.  
  943. +++++++++++++++++++++++++++
  944.  
  945. >From Gordon Tillman <got@mindspring.com>
  946. Date: 15 Oct 1995 14:07:55 GMT
  947. Organization: n/a
  948.  
  949. Hi Adam,
  950.  
  951. In article <ACA4612096681197B@park78.demon.co.uk> Adam Lloyd,
  952. adam@park78.demon.co.uk writes:
  953. >Are there any good implementations of Perl for the Mac, other than the
  954. Perl
  955. >Tool for MPW? I'm thinking along the lines of something stand-alone...
  956.  
  957.  
  958. You can use MacPerl.  It's been a while since I got it, so there is
  959. probably a newer version around.  I have version 4.1.3, Patchlevel 36.
  960.  
  961. In the about box it said the Mac version was written by:
  962.  
  963.     Matthias Neeracher    neeri@iis.e.ethz.ch
  964.     Tim Endres            time@ice.com
  965.  
  966. You can probably find it at the usual Mac archives.  If you cannot, let
  967. me know and I will see if I can help.  This version does not require MPW.
  968.  
  969. --gordon tillman
  970. - ----------------------------------------------------------------------
  971.       Internet: got@mindspring.com       |  Voice: 615-238-6506
  972.                 gordyt@aol.com           |    Fax: 615-238-4924
  973. America Online: GordyT                   |US Mail: 7312 Flagstone Drive
  974.     CompuServe: 74372,1071               |         Ooltewah, TN  37363
  975. - ----------------------------------------------------------------------
  976.  
  977. ---------------------------
  978.  
  979. >From hellstrm@jaguNET.com (Ben Hellstrom)
  980. Subject: Popup Menus in 9-pt geneva ?????
  981. Date: Tue, 03 Oct 1995 20:27:46 -0400
  982. Organization: jaguNET Access Services
  983.  
  984. Many of the utilities I have have nice little popups in 9-pt geneva.  They
  985. dont have MDEFs (which means the MDEFs are either embedded in other code
  986. resources or they are using the standard MDEF).
  987.  
  988. Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  989. Do I have to switch the system font?  If so, how?
  990.  
  991.  
  992. TIA
  993.  
  994. -- 
  995. Ben Hellstrom
  996. hellstrm@jaguNET.com
  997.  
  998. +++++++++++++++++++++++++++
  999.  
  1000. >From tim@dierks.org (Tim Dierks)
  1001. Date: Wed, 04 Oct 1995 00:35:56 -0700
  1002. Organization: Best Internet Communications
  1003.  
  1004. In article <hellstrm-0310952027460001@brian.jagunet.com>,
  1005. hellstrm@jaguNET.com (Ben Hellstrom) wrote:
  1006.  
  1007. >Many of the utilities I have have nice little popups in 9-pt geneva.  They
  1008. >dont have MDEFs (which means the MDEFs are either embedded in other code
  1009. >resources or they are using the standard MDEF).
  1010. >
  1011. >Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  1012. >Do I have to switch the system font?  If so, how?
  1013.  
  1014. Mmmm.... Code (including way-cool trap patches!)
  1015.  
  1016. Setting the width will need to be fixed to use a UPP for native
  1017. applications. Or, just hack it out. It's sick anyway. Unpatching traps?! Yuk.
  1018.  
  1019. - Tim.
  1020.  
  1021. Note: I tried to keep this from being wrapped.
  1022.  
  1023. // Call just like PopUpMenuSelect, only you can set the font, size, and
  1024. width of the popup menu.
  1025. //  Pass 0 for font, size, or width to use the defaults.
  1026. long
  1027. PopUpMenuSelectWithFontAndWidth(MenuHandle menu,short top,short left,short
  1028. popUpItem,short font,short size,short width)
  1029. {   long                menuChoice;                     // Stores the
  1030. chosen menu & item
  1031.     short               saveSysFontFam,saveSysFontSize; // Room for saving
  1032. the current system font and size
  1033.     GrafPtr             wMgrPort;                       // Pointer to the
  1034. window manager port
  1035.     CalcMenuSizeProc    oldCalcMenuSize;                // Address of the
  1036. old CalcMenuSize procedure
  1037.     
  1038.     // First, we'll clean up after buggy software.  A number of commercial
  1039. products
  1040.     // (word processors are most common) screw up the window manager port;
  1041. they leave the
  1042.     // txSize field set to 12.  It and the txFont field should always be
  1043. left set to 0;
  1044.     // this makes them the system font and size.  So first thing we do is
  1045. clean up
  1046.     // after these miscreants.
  1047.     
  1048.     GetWMgrPort(&wMgrPort);
  1049.     SetPort(wMgrPort);
  1050.     TextFont(0);
  1051.     TextSize(0);
  1052.     
  1053.     // Now, if we're going to change the font or the size, then we
  1054. remember the old
  1055.     // system font and size so they can be restored later
  1056.     
  1057.     if (font != 0 || size != 0)
  1058.     {   saveSysFontFam = *(short*)SysFontFam;
  1059.         saveSysFontSize = *(short*)SysFontSize;
  1060.         
  1061.         if (font != 0)
  1062.             *(short*)SysFontFam = font;
  1063.         if (size != 0)
  1064.             *(short*)SysFontSize = size;
  1065.         
  1066.         *(long*)LastSPExtra = -1;           // This forces the system to
  1067. recognize our changes
  1068.     }
  1069.     
  1070.     // Now we need to set the width.  Unfortunately, it's not as easy as
  1071. changing the
  1072.     // font and size; we need to patch CalcMenuSize so we can fake the
  1073. width of the menu
  1074.     if (width != 0)
  1075.     {   oldCalcMenuSize = (CalcMenuSizeProc)NGetTrapAddress(0x148,ToolTrap);
  1076.         
  1077.         gCMSParms.oldCMS = oldCalcMenuSize;
  1078.         gCMSParms.theMenu = menu;
  1079.         gCMSParms.width = width;
  1080.         
  1081.         NSetTrapAddress((long)CalcMenuSizePatch,0x148,ToolTrap);
  1082.         
  1083.         // Now we should zero out the menu's stored width and height to
  1084. ensure that
  1085.         // its size will be recalculated
  1086.         
  1087.         (**menu).menuWidth = 0;
  1088.         (**menu).menuHeight = 0;
  1089.     }
  1090.     
  1091.     menuChoice = PopUpMenuSelect(menu,top,left,popUpItem);
  1092.     
  1093.     // Now we restore the original CalcMenuSize if we changed it
  1094.     if (width != 0)
  1095.         NSetTrapAddress((long)oldCalcMenuSize,0x148,ToolTrap);
  1096.     
  1097.     // Now we restore the original font and size to their places
  1098.     // if we changed them
  1099.     if (font != 0 || size != 0)
  1100.     {   *(short*)SysFontFam = saveSysFontFam;
  1101.         *(short*)SysFontSize = saveSysFontSize;
  1102.         *(long*)LastSPExtra = -1;
  1103.     }
  1104.     
  1105.     // return the chosen menu & item
  1106.     return menuChoice;
  1107. }
  1108.  
  1109. // This is the patch to CalcMenuSize; first, we call the original
  1110. // to calculate the size.  If the menu being calculated is ours,
  1111. // we then change the width to our stored width.  Note that this
  1112. // is a tail patch; while still frowned upon, these are not as
  1113. // bad as they used to be, and it's really the best way to
  1114. // accomplish our task.
  1115. //
  1116. // Our use of a global to store the original CalcMenuSize and
  1117. // other data implies we'll be sure that A5 hasn't been changed;
  1118. // we can be fairly certain this is true in this particular
  1119. // case.
  1120.  
  1121. static pascal void
  1122. CalcMenuSizePatch(MenuHandle theMenu)
  1123. {   
  1124.     gCMSParms.oldCMS(theMenu);          // Call the original CalcMenuSize();
  1125.     
  1126.     if (theMenu == gCMSParms.theMenu)   // If it's our menu, fix up the width
  1127.         (**theMenu).menuWidth = gCMSParms.width;
  1128. }
  1129.  
  1130. -- 
  1131. Tim Dierks - Software Haruspex - tim@dierks.org
  1132. If you can't lick 'em, stick 'em on with a big piece of tape. - Negativland
  1133.  
  1134. +++++++++++++++++++++++++++
  1135.  
  1136. >From Richard Wesley <hawkfish@punchdeck.com>
  1137. Date: 4 Oct 1995 14:42:41 GMT
  1138. Organization: Punch Deck Consulting
  1139.  
  1140. hellstrm@jaguNET.com (Ben Hellstrom) wrote:
  1141. >Many of the utilities I have have nice little popups in 9-pt geneva.  They
  1142. >dont have MDEFs (which means the MDEFs are either embedded in other code
  1143. >resources or they are using the standard MDEF).
  1144. >
  1145. >Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  1146. >Do I have to switch the system font?  If so, how?
  1147.  
  1148. If you are using PowerPlant and Constructor, just set the text traits of
  1149. the popup control to geneva-9.
  1150.  
  1151. If you are doing this from scratch, then what you need to do is:
  1152.  
  1153. 1) make the current port the window that you want to add the control to;
  1154. 2) set the font to geneva-9
  1155. 3) make sure that the controlKind has kControlUsesOwningWindowsFontVariant;
  1156. 4) instantiate the control.
  1157.  
  1158. No trap patching should be required.
  1159.  
  1160. - rmgw
  1161.  
  1162. http://www.punchdeck.com/hawkfish/PunchDeck.html
  1163.  
  1164. - --------------------------------------------------------------------------
  1165. Richard Wesley  hawkfish@punchdeck.com | "What was that popping sound?"
  1166. Punch Deck Consulting pnchdeck@aol.com | "A paradigm shifting without a
  1167.      Macintosh Software Development    |  clutch."  - Dilbert (Scott Adams)
  1168. - --------------------------------------------------------------------------
  1169.  
  1170.  
  1171.  
  1172. +++++++++++++++++++++++++++
  1173.  
  1174. >From jeremyr@dcs.qmw.ac.uk (Jeremy Roussak)
  1175. Date: 4 Oct 1995 19:45:07 GMT
  1176. Organization: Queen Mary & Westfield College, London, England
  1177.  
  1178. In article <hellstrm-0310952027460001@brian.jagunet.com>
  1179. hellstrm@jaguNET.com (Ben Hellstrom) writes:
  1180.  
  1181. > Many of the utilities I have have nice little popups in 9-pt geneva.  They
  1182. > dont have MDEFs (which means the MDEFs are either embedded in other code
  1183. > resources or they are using the standard MDEF).
  1184. > Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  1185. > Do I have to switch the system font?  If so, how?
  1186.  
  1187. Use the Popup CDEF with the "use window font" bit set and set the font
  1188. to 9 point Geneva. 
  1189.  
  1190. Jeremy
  1191.  
  1192. +++++++++++++++++++++++++++
  1193.  
  1194. >From jbruni@primenet.com (Joseph Bruni)
  1195. Date: Wed, 04 Oct 1995 23:21:58 -0700
  1196. Organization: Primenet
  1197.  
  1198. In article <hellstrm-0310952027460001@brian.jagunet.com>,
  1199. hellstrm@jaguNET.com (Ben Hellstrom) wrote:
  1200.  
  1201. > Many of the utilities I have have nice little popups in 9-pt geneva.  They
  1202. > dont have MDEFs (which means the MDEFs are either embedded in other code
  1203. > resources or they are using the standard MDEF).
  1204. > Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  1205. > Do I have to switch the system font?  If so, how?
  1206.  
  1207. Use the control manager to do the popup for you. Just make sure you use
  1208. the "useWFont" variant.
  1209.  
  1210. +++++++++++++++++++++++++++
  1211.  
  1212. >From <brick@spirit.com.au>
  1213. Date: 6 Oct 1995 07:42:08 GMT
  1214. Organization: Spirit Networks
  1215.  
  1216. hellstrm@jaguNET.com (Ben Hellstrom) wrote:
  1217.  
  1218. >Many of the utilities I have have nice little popups in 9-pt geneva.  >They dont have MDEFs (which means the MDEFs are either embed=
  1219. ded in
  1220. >other code resources or they are using the standard MDEF).
  1221. >
  1222. >Can anyone give me a clue as to how to produce a menu in 9-point
  1223. >geneva? Do I have to switch the system font?  If so, how?
  1224.  
  1225. Ben,
  1226.  
  1227. As you know, to create a control that uses the standard pop-up control
  1228. definition function, you specify the popupMenuProc constant in the
  1229. procID field of the resource description for the control.
  1230.  
  1231. If you add the constant useWFont to popupMenuProc, the pop-up title
  1232. and menu item text will be drawn in the graphics port's current font
  1233. rather than the system font.  So all you have to do then is set your
  1234. graphics port font and size to Geneva 9 point and you will
  1235. get what you want.
  1236.  
  1237. K. J. Bricknell
  1238. Canberra
  1239. Australia
  1240.  
  1241.  
  1242. +++++++++++++++++++++++++++
  1243.  
  1244. >From Kenn@owl-uk.co.uk (Ken Nicolson)
  1245. Date: Fri, 13 Oct 1995 10:22:33 GMT
  1246. Organization: Office Workstations Limited
  1247.  
  1248. hellstrm@jaguNET.com (Ben Hellstrom) wrote:
  1249.  
  1250. >Many of the utilities I have have nice little popups in 9-pt geneva.  They
  1251. >dont have MDEFs (which means the MDEFs are either embedded in other code
  1252. >resources or they are using the standard MDEF).
  1253.  
  1254. >Can anyone give me a clue as to how to produce a menu in 9-point geneva? 
  1255. >Do I have to switch the system font?  If so, how?
  1256.  
  1257. Here's the solution I came up with. Pass in the menu handle, position
  1258. and font number and size, and get returned the string of the menu
  1259. option, or -1 if no selection.
  1260.  
  1261. I assume Color QuickDraw, but it seems to work even if I switch my
  1262. monitor to monochrome.
  1263.  
  1264. The code was written after reading the TechNote TB-550, Menu Managers
  1265. Q&A. Apparently, this is how the Popup Control gadget does its stuff.
  1266.  
  1267. Maybe a routine like this should go into a FAQ somewhere, as it seems
  1268. a common thing to want to do, but how to do it is deeply buried on the
  1269. developer CDs. 
  1270.  
  1271. int PopUpMenuSelectWithFont(MenuHandle hMenu,
  1272.                             int x, int y,
  1273.                             short txFont, short txSize,
  1274.                             char *szValue)
  1275. {
  1276.         SInt32          lPopUpResult;
  1277.         int             nPos;
  1278.         SInt16          saveFamily;
  1279.         SInt16          saveSize;
  1280.         SInt32          saveLastSP;
  1281.         CGrafPtr        wmPort;
  1282.         GrafPtr currentPort;
  1283.  
  1284.         // Save current viewport
  1285.         GetPort( ¤tPort );
  1286.  
  1287.         // Save current system default fonts
  1288.         saveFamily = LMGetSysFontFam();
  1289.         saveSize   = LMGetSysFontSize();
  1290.         saveLastSP = LMGetLastSPExtra();
  1291.  
  1292.         GetCWMgrPort( &wmPort );
  1293.  
  1294.         SetPort( (GrafPtr) wmPort );
  1295.  
  1296.         TextSize( txSize );
  1297.  
  1298.         // Install temporary font as system font
  1299.         LMSetSysFontFam( txFont );
  1300.         LMSetSysFontSize( txSize );
  1301.         LMSetLastSPExtra( (SInt32) -1 );
  1302.  
  1303.         // Process the pop-up menu
  1304.         lPopUpResult = PopUpMenuSelect( hMenu, y, x, 1 );
  1305.  
  1306.         // Restore port
  1307.         SetPort( currentPort );
  1308.  
  1309.         // Restore system default fonts
  1310.         LMSetSysFontFam( saveFamily );
  1311.         LMSetSysFontSize( saveSize );
  1312.         LMSetLastSPExtra( saveLastSP );
  1313.  
  1314.         if (HIWORD(lPopUpResult) != 0)
  1315.         {
  1316.                 nPos = LOWORD( lPopUpResult );
  1317.                 getitem( hMenu, nPos, pszValue );
  1318.         }
  1319.         else
  1320.                 nPos = -1;
  1321.  
  1322.         return nPos;
  1323. }
  1324.  
  1325. The LMGet/LMSet functions are from CodeWarrior's LowMem.h to hide the
  1326. access to system variables.
  1327.  
  1328. Hope the types are correct - we have a set of #defines to hide a lot
  1329. of Mac specifics, so I've used the base definitions from memory.
  1330.  
  1331. Ken
  1332.  
  1333.  
  1334. ---------------------------
  1335.  
  1336. >From daf@bbn.com (David Fagan)
  1337. Subject: Q: using OSAExecute to singlestep AppleScript
  1338. Date: Tue, 10 Oct 1995 01:35:41 -0400
  1339. Organization: BBN Educational Technologies
  1340.  
  1341. My application would like to execute one line of AppleScript at a time.
  1342. The lines originate as text, so I call OSACompileExecute. Unfortunately,
  1343. the AppleScript interpreter wants entire scripts or handlers at a time, so
  1344. if I pass a line such as,
  1345.  
  1346. tell application "Scriptable Text Editor"
  1347.  
  1348. I get back the error you'd expect if you tried to run the above out of the
  1349. script editor, namely, "Expecting end tell..."
  1350.  
  1351. Anyone have an idea to pass the interpreter one line at a time?
  1352.  
  1353. I suppose it has something to do with the contextID parameter to
  1354. OSACompileExecute, but nothing I've done with it helps, and IM Scripting
  1355. doesn't provide any clues that I can see.
  1356.  
  1357. Thanks
  1358.  
  1359. David Fagan
  1360. daf@bbn.com
  1361.  
  1362. +++++++++++++++++++++++++++
  1363.  
  1364. >From jonpugh@netcom.com (Jon Pugh)
  1365. Date: Fri, 13 Oct 1995 22:15:04 GMT
  1366. Organization: Will hack for food
  1367.  
  1368. David Fagan (daf@bbn.com) wrote:
  1369. > My application would like to execute one line of AppleScript at a time.
  1370. > The lines originate as text, so I call OSACompileExecute. Unfortunately,
  1371. > the AppleScript interpreter wants entire scripts or handlers at a time, so
  1372. > if I pass a line such as,
  1373.  
  1374. > tell application "Scriptable Text Editor"
  1375.  
  1376. > I get back the error you'd expect if you tried to run the above out of the
  1377. > script editor, namely, "Expecting end tell..."
  1378.  
  1379. > Anyone have an idea to pass the interpreter one line at a time?
  1380.  
  1381. You can't do this.  There is no AppleScript support for single stepping.
  1382.  
  1383. I spoke with the DTS folks helping you and we discussed a possible solution,
  1384. but not knowing what you are trying to do makes us unable to determine if
  1385. this will work for what you are trying to do.
  1386.  
  1387. Basically, you can do what the script debugging editors do.  That's to use
  1388. the OSASendProc to pause before and/or after each Apple event.  Given this
  1389. procedure, which is simply a wrapper for AESend which AppleScript calls 
  1390. instead of calling AESend, you can decide when and/or if to actually send
  1391. the events.  As I stated before though, not knowing what you are trying
  1392. to accomplish means that I don't know if this will suffice.
  1393.  
  1394. Jon
  1395.  
  1396.  
  1397. ---------------------------
  1398.  
  1399. >From samny@nyc.pipeline.com (Ed Samuels)
  1400. Subject: Reading Notification Manager queue?
  1401. Date: 9 Oct 1995 22:54:23 -0400
  1402. Organization: The Pipeline
  1403.  
  1404. Is there any way to look into the queue of the Notification Manager? I
  1405. would like to be able to take a notification request that is generated by
  1406. another application off of the queue. IM only describes the NMInstall and
  1407. NMRemove functions, both of which require that you already have a pointer
  1408. to the notification request. It makes no reference to any other NM
  1409. routines, and it seems to imply that there are no others!  
  1410.  
  1411.     Most of the other OS routines have some function that returns a pointer
  1412. to the bottom of the queue, but apparently the Notification Manager
  1413. doesn't. I can't even find a low-memory global that points to it! If there
  1414. isn't an easier way, I think I'll have to patch the routine to find out
  1415. what is going on. That is something that I DO NOT want to do--NMInstall
  1416. preserves most registers and does not move memory, so such a patch would be
  1417. very shaky, and definitely much too complicated for my purposes. 
  1418.  
  1419.     If anyone can direct me to any info about the Notification Manager that
  1420. describes more than what is said in Inside Macintosh, thanks. :)  
  1421. ___________________________________ 
  1422. Richard Samuels 
  1423. samny@nyc.pipeline.com
  1424.  
  1425. +++++++++++++++++++++++++++
  1426.  
  1427. >From brians@pbcomputing.com (Brian Stern)
  1428. Date: 14 Oct 1995 03:37:16 GMT
  1429. Organization: The University of Texas at Austin, Austin, Texas
  1430.  
  1431. Richard,
  1432.  
  1433. The OS queue used by the Notification Manager is undocumented.  An earlier
  1434. version of Macsbug used to know about the lowmem global, but the current
  1435. version seems to have forgotten its name :-/  A quick look at NMInstall
  1436. shows a suspicious check to location 0x0DD5.
  1437.  
  1438. I have an INIT that patches NMInstall and keeps track of the records that
  1439. are posted.  As I was developing this I first walked the queue but in the
  1440. end decided that since it was undocumented I would do it another way.  You
  1441. can be sure things won't change before Copland anyway.  Not all requests
  1442. that are added to the queue are removed by the Notification manager. 
  1443. There is a flags field in each NMRecord and apparently once a Notification
  1444. is shown a bit is set so that the notification isn't shown again.
  1445.  
  1446. Good luck,
  1447.  
  1448. Brian  }:-{)}
  1449.  
  1450. In article <45cn8v$1ek@pipe4.nyc.pipeline.com>, samny@nyc.pipeline.com (Ed
  1451. Samuels) wrote:
  1452.  
  1453. <Is there any way to look into the queue of the Notification Manager? I
  1454. <would like to be able to take a notification request that is generated by
  1455. <another application off of the queue. IM only describes the NMInstall and
  1456. <NMRemove functions, both of which require that you already have a pointer
  1457. <to the notification request. It makes no reference to any other NM
  1458. <routines, and it seems to imply that there are no others!  
  1459. <    Most of the other OS routines have some function that returns a pointer
  1460. <to the bottom of the queue, but apparently the Notification Manager
  1461. <doesn't. I can't even find a low-memory global that points to it! If there
  1462. <isn't an easier way, I think I'll have to patch the routine to find out
  1463. <what is going on. That is something that I DO NOT want to do--NMInstall
  1464. <preserves most registers and does not move memory, so such a patch would be
  1465. <very shaky, and definitely much too complicated for my purposes. 
  1466. <    If anyone can direct me to any info about the Notification Manager that
  1467. <describes more than what is said in Inside Macintosh, thanks. :)  
  1468. <___________________________________ 
  1469. <Richard Samuels 
  1470. <samny@nyc.pipeline.com
  1471.  
  1472. ____________________________________________________________________
  1473. Brian  Stern  {;-{)}                  Toolbox commando and Menu bard                  Stern@metrowerks.com                          BrianS@pbcomputing.com
  1474. INIT Writing FAQ etc. at <ftp://ftp.pbcomputing.com//Guests/BrianS/>
  1475.  
  1476. ---------------------------
  1477.  
  1478. End of C.S.M.P. Digest
  1479. **********************
  1480.